package week5;

import java.util.Scanner;
import java.util.Random;

public class PP0507 {
    public static void main(String[] args) {
        final int s =0, j = 1, b = 2;
        int num1 = 0, num2;
        int draw = 0, win = 0, loose = 0;;

        while(true) {
            Scanner sc = new Scanner(System.in);
            System.out.print("输入你的出招(石头(0)、剪刀(1)、布(2)、退出(其他任意数字): ");
            num1 = sc.nextInt();

            Random r = new Random();
            num2 = r.nextInt(3);
            if (num1 > 2)
                break;
            else if (num1 == 0){
                System.out.print("你出的是石头;\n电脑出的是");
                if (num2 == 0){
                    System.out.println("石头;");
                    draw++;
                    System.out.println("平局.");
                }
                else if (num2 == 2){
                    System.out.println("剪刀;");
                    win++;
                    System.out.println("你赢了。");
                }
                else{
                    System.out.println("布;");
                    loose++;
                    System.out.println("你输了.");
                }
            }
            else if (num1 == 1){
                System.out.print("你出的是剪刀;\n电脑出的是");
                if (num2 == 0){
                    System.out.println("石头;");
                    loose++;
                    System.out.println("你输了.");
                }
                else if (num2 == 2){
                    System.out.println("剪刀;");
                    draw++;
                    System.out.println("平局.");
                }
                else{
                    System.out.println("布;");
                    win++;
                    System.out.println("你赢了.");
                }
            }
            else {
                System.out.print("你出的是布;\n电脑出的是");
                if (num2 == 0){
                    System.out.println("石头;");
                    win++;
                    System.out.println("你赢了");
                }
                else if (num2 == 2){
                    System.out.println("剪刀;");
                    loose++;
                    System.out.println("你输了.");
                }
                else{
                    System.out.println("布;");
                    draw++;
                    System.out.println("平局.");
                }
            }
        }
        System.out.println("游戏结束,你赢了" + win + "把,输了" + loose + "把,和局" + draw + "把.");
        }
    }
